using UnityEngine;

namespace Crosstales.UI
{
    // [Assembly-CSharp-firstpass.dll].Crosstales.UI.WindowManager
    public class WindowManager : MonoBehaviour
    {
        // Fields
        public float Speed;
        public UnityEngine.GameObject[] Dependencies;
        public bool ClosedAtStart;
        private Crosstales.UI.UIFocus focus;
        private bool open;
        private bool close;
        private UnityEngine.Vector3 startPos;
        private UnityEngine.Vector3 centerPos;
        private UnityEngine.Vector3 lerpPos;
        private float openProgress;
        private float closeProgress;
        private UnityEngine.GameObject panel;
        private UnityEngine.Transform tf;
        
        // Methods
        private void Start()
        {
            var val_5;
            this.tf = this.transform;
            val_5 = this;
            this.panel = this.tf.Find(n:  -1610604617).gameObject;
            UnityEngine.Vector3 val_4 = this.tf.position;
            this.startPos = val_4;
            mem[1152921504930430464] = val_4.y;
            mem[1152921504930430468] = val_4.z;
            if(this.ClosedAtStart == false)
            {
                goto label_4;
            }
            
            this.ClosePanel();
            this.panel.SetActive(value:  false);
            if(this.Dependencies == null)
            {
                    return;
            }
            
            if(this.Dependencies.Length < 1)
            {
                    return;
            }
            
            label_10:
            if(0 >= this.Dependencies.Length)
            {
                goto label_8;
            }
            
            1152921504974982128.SetActive(value:  false);
            val_5 = 0 + 1;
            if(val_5 < this.Dependencies.Length)
            {
                goto label_10;
            }
            
            return;
            label_4:
            this.OpenPanel();
            return;
            label_8:
        }
        private void Update()
        {
            var val_10;
            UnityEngine.Vector3 val_13;
            UnityEngine.Vector3 val_15;
            val_10 = UnityEngine.Screen.width;
            int val_2 = UnityEngine.Screen.height;
            double val_10 = (double)val_10;
            val_10 = val_10 * 0.5f;
            mem[1152921504930430480] = 0;
            this.centerPos = val_10;
            if((this.open == false) || (this.openProgress >= 0))
            {
                goto label_1;
            }
            
            float val_3 = UnityEngine.Time.deltaTime;
            val_3 = this.Speed * val_3;
            val_3 = this.openProgress + val_3;
            this.openProgress = val_3;
            var val_4 = (val_3 >= 0) ? 0.5f : 0f;
            val_13 = this.lerpPos;
            val_15 = this.centerPos;
            goto label_3;
            label_1:
            if(this.close == false)
            {
                    return;
            }
            
            if(this.closeProgress >= 0)
            {
                goto label_5;
            }
            
            float val_5 = UnityEngine.Time.deltaTime;
            val_5 = this.Speed * val_5;
            val_5 = this.closeProgress + val_5;
            this.closeProgress = val_5;
            val_13 = this.lerpPos;
            val_15 = this.startPos;
            label_3:
            val_15 = val_15 - val_13;
            float val_7 = S4 - S2;
            val_7 = ((val_5 >= 0) ? 0.5f : 0f) * val_7;
            this.tf.position = new UnityEngine.Vector3() {x = val_13 + val_15, y = val_13 + val_15, z = S2 + val_7};
            return;
            label_5:
            this.panel.SetActive(value:  false);
            if(this.Dependencies == null)
            {
                    return;
            }
            
            if(this.Dependencies.Length < 1)
            {
                    return;
            }
            
            label_12:
            if(0 >= this.Dependencies.Length)
            {
                goto label_10;
            }
            
            1152921504974982128.SetActive(value:  false);
            val_10 = 0 + 1;
            if(val_10 < this.Dependencies.Length)
            {
                goto label_12;
            }
            
            return;
            label_10:
        }
        public void SwitchPanel()
        {
            if(this.open != false)
            {
                    this.ClosePanel();
                return;
            }
            
            this.OpenPanel();
        }
        public void OpenPanel()
        {
            this.panel.SetActive(value:  true);
            if((this.Dependencies == null) || (this.Dependencies.Length < 1))
            {
                goto label_3;
            }
            
            var val_4 = 0;
            label_6:
            if(val_4 >= this.Dependencies.Length)
            {
                goto label_4;
            }
            
            1152921504974982128.SetActive(value:  true);
            val_4 = val_4 + 1;
            if(val_4 < this.Dependencies.Length)
            {
                goto label_6;
            }
            
            label_3:
            this.focus = this.gameObject.GetComponent<System.Object>();
            this.focus.OnPanelEnter();
            UnityEngine.Vector3 val_3 = this.tf.position;
            this.lerpPos = val_3;
            mem[1152921504930430488] = val_3.y;
            mem[1152921504930430492] = val_3.z;
            this.open = true;
            this.close = false;
            this.openProgress = 0f;
            return;
            label_4:
        }
        public void ClosePanel()
        {
            UnityEngine.Vector3 val_1 = this.tf.position;
            this.lerpPos = val_1;
            mem[1152921504930430488] = val_1.y;
            mem[1152921504930430492] = val_1.z;
            this.open = true;
            this.close = true;
            this.closeProgress = 0f;
        }
        public WindowManager()
        {
            this.Speed = 3f;
            this.ClosedAtStart = true;
        }
    
    }

}
